<template src="./index.html"></template>

<script>
import MedicalRecordChildbearingHistoryService from "../../../../../_services/medicalRecordChildbearingHistory.service";
export default {
  name: "TianDingPatientMeBirthHistoryComponent",
  data() {
    return {
      birthHistoryList: []
    };
  },
  mounted() {
    this.getChildbearingHistoryByUserID();
  },
  methods: {
    getChildbearingHistoryByUserID() {
      this.indicator$.open("正在加载...");
      let user = JSON.parse(this.local$.getItem("tdUser"));
      let params = {};
      params.userid = user.UserID;
      MedicalRecordChildbearingHistoryService.getChildbearingHistoryByUserID(
        params
      ).then(response => {
        console.log(response);
        if (response && response.Data) {
          this.birthHistoryList = response.Data;
          this.indicator$.close();
        }
      });
    },
    showItem(item) {
      let flag = false;
      if (item) {
        let arr = item.split(",");
        arr.forEach(element => {
          switch (element) {
            case "未着床":
            case "生化":
            case "宫外孕":
            case "葡萄胎":
            case "主动放弃":
              flag = true;
              break;
            default:
              flag = false;
              break;
          }
        });
      }
      return flag;
    },
    btnModify(item) {
      this.local$.removeItem("tdBirthHistory");
      if (item !== undefined) {
        this.local$.setItem("tdBirthHistory", JSON.stringify(item));
        this.$router.push({
          name: "tdPatientMeMedicalBirthHistoryModify",
          params: item
        });
      } else {
        this.$router.push({
          name: "tdPatientMeMedicalBirthHistoryModify"
        });
      }
    },
    btnPrev() {
      let menu = JSON.parse(this.local$.getItem("tdMeLeftMenus"));
      menu.prev = "prev";
      this.$emit("change", menu);
    },
    btnNext() {
      let menu = JSON.parse(this.local$.getItem("tdMeLeftMenus"));
      menu.next = "next";
      this.$emit("change", menu);
    }
  }
};
</script>

<style lang="scss">
.medical-record-birth-history {
  .btn-box {
    margin-bottom: 20px;
  }
}
</style>
